FROM ubuntu:18.04

MAINTAINER wyn 'sparrow'
ADD sources.list /etc/apt/

# 安装git、python、nginx、supervisor等，并清理缓存

RUN apt-get update && \
    apt-get upgrade -y

RUN apt-get install -y python3
RUN apt-get install -y python3-dev

RUN apt-get install -y python3-setuptools
RUN apt-get install -y python3-pip
RUN apt-get install -y python-pip
RUN apt-get install -y nginx
RUN apt-get install -y supervisor
RUN apt-get install -y libmysqlclient-dev

RUN pip install --upgrade -i https://pypi.doubanio.com/simple/ pip setuptools
RUN rm -rf /var/lib/apt/lists/*


RUN pip3 install -i https://pypi.doubanio.com/simple/ uwsgi


# 环境变量

ENV MYSQL_DATABASE_NAME Essay
# ENV EMAIL_HOST_USER myemail@email.com
# ENV EMAIL_HOST_PASSWORD my-secret-password


# nginx、supervisor配置

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
COPY nginx-app.conf /etc/nginx/sites-available/default
COPY supervisor-app.conf /etc/supervisor/conf.d/


# 安装项目所需python第三方库

COPY requirements.txt /home/docker/code/LifeEssays/

RUN pip3 install -i https://pypi.doubanio.com/simple/ -r /home/docker/code/LifeEssays/requirements.txt


# uwsgi.ini 及 uwsgi_params

COPY . /home/docker/code/


EXPOSE 80
CMD ["supervisord", "-n"]